home *** CD-ROM | disk | FTP | other *** search
- #include <dos.h>
-
- #define unint unsigned int
- #define uchar unsigned char
-
- #define TESTING
-
- /*
- FILES and BUFFERS are free functions. Use them without restriction anywhere.
-
- Author: Ben Morris
- Date : July 2nd, 1992.
-
- */
-
- /*
- Code to count number of FILES as set in config.sys.
- */
-
- int FILES( void )
- {
- union REGS regs;
- struct SREGS sregs;
- unint far *ptr;
- int numfiles = 0;
-
- regs.h.ah = 0x52;
- intdosx( ®s, ®s, &sregs );
-
- ptr = (unint far *) MK_FP( sregs.es, regs.x.bx+0x04 );
- ptr = (unint far *) MK_FP( ptr[1], ptr[0] );
-
- while( FP_OFF( ptr ) != 0xFFFF )
- {
- numfiles += ptr[2];
- ptr = (unsigned int far *) MK_FP( ptr[1], ptr[0] );
- }
-
- return numfiles;
- }
-
- /*
- Code to count number of BUFFERS as set in CONFIG.SYS.
- */
-
- int BUFFERS( void )
- {
- uchar far *ptr;
- struct REGPACK regs;
- int numbuffers = 0;
-
- regs.r_ax = 0x5200;
-
- intr( 0x21, ®s );
- ptr = (uchar far *) MK_FP( regs.r_es, regs.r_bx );
-
- numbuffers = *(ptr+0x3F);
-
- return numbuffers;
- }
-
- #ifdef TESTING
- void main( void )
- {
- printf( "FILES=%d\n", FILES() );
- printf( "BUFFERS=%d\n", BUFFERS() );
- }
- #endif
-